home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / crsbas.zip / CROSSBAS.DOC < prev    next >
Encoding:
Text File  |  1990-12-01  |  42.7 KB  |  1,085 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.                                    CrossBas Manual
  24.  
  25.                        Power-BASIC Cross-Reference List Creator
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.                                   November 13, 1989 (1990)
  34.                                   (c) Lester L. Noll
  35.                               CompuServe Id:  72250,2551
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.                                      CrossBas.exe
  45.                                     version 1.00P
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.                                     ContentsContents
  60.  
  61.  
  62.                   1  Disclaimer  . . . . . . . . . . . . . . . . . . 1
  63.                   2  Copyright and Usage . . . . . . . . . . . . . . 1
  64.                   3  Introduction  . . . . . . . . . . . . . . . . . 1
  65.                   4  Running CrossBas  . . . . . . . . . . . . . . . 2
  66.                   5  Command Line Options  . . . . . . . . . . . . . 2
  67.                   6  Changing Defaults File  . . . . . . . . . . . . 5
  68.                   7  The Summary Report  . . . . . . . . . . . . . . 6
  69.                   8  What CrossBas Does  . . . . . . . . . . . . . . 8
  70.                      8.1  Initialize . . . . . . . . . . . . . . . . 8
  71.                      8.2  InitScreen . . . . . . . . . . . . . . . . 8
  72.                      8.3  ReadCmdLine  . . . . . . . . . . . . . . . 9
  73.                      8.4  OpenFiles  . . . . . . . . . . . . . . . . 9
  74.                      8.5  CalcFileNames  . . . . . . . . . . . . . . 9
  75.                      8.6  ReadDefaults . . . . . . . . . . . . . . . 9
  76.                      8.7  CheckStringSpace . . . . . . . . . . . .  10
  77.                      8.8  CalcWordArraySize  . . . . . . . . . . .  10
  78.                      8.9  PrintScreenTop . . . . . . . . . . . . .  10
  79.                      8.10  ReadAndParseData  . . . . . . . . . . .  10
  80.                      8.11  PrintScreen1  . . . . . . . . . . . . .  10
  81.                      8.12  Compare . . . . . . . . . . . . . . . .  11
  82.                      8.13  PrintScreen2  . . . . . . . . . . . . .  11
  83.                      8.14  Sort  . . . . . . . . . . . . . . . . .  11
  84.                      8.15  PrintScreen3  . . . . . . . . . . . . .  11
  85.                      8.16  PrintList . . . . . . . . . . . . . . .  11
  86.                      8.17  PrintReportBtm  . . . . . . . . . . . .  12
  87.                      8.18  PrintScreen4  . . . . . . . . . . . . .  12
  88.                      8.19  End Routines  . . . . . . . . . . . . .  12
  89.  
  90.                Appendix A  CrossBas Files                           13
  91.  
  92.                Appendix B  Modification History                     15
  93.  
  94.                Appendix C  Power-BASIC Reserved Words               17
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.                                           i
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.                                          ii
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.                                     FiguresFigures
  190.  
  191.  
  192.                Figure 1: Summary Report Example  . . . . . . . . . . 8
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.                                          iii
  241.  
  242.  
  243.  
  244.           CROSSBAS.DOC                CrossBas Manual                page 1
  245.  
  246.  
  247.  
  248.           1  Disclaimer
  249.           1  Disclaimer
  250.  
  251.  
  252.                Hear ye, hear ye!  Be it known that the author hereby
  253.           disclaims all warranties expressed or implied as to the quality
  254.           or performance of this program.  The author will not be held
  255.           liable for any lost profits, lost savings or any other direct,
  256.           indirect, incidental or consequential damages resulting from the
  257.           use of this program.  Your use of this program constitutes your
  258.           agreement to this disclaimer and your release of the author from
  259.           any form of liability or litigation.  (Really gives you
  260.           confidence, huh?)
  261.  
  262.  
  263.           2  Copyright and Usage
  264.           2  Copyright and Usage
  265.  
  266.  
  267.                This program, as well as its accompanying files and
  268.           documents, is copyright by the author, Lester L. Noll.  You are
  269.           free to use and distribute it as you wish as long as you charge
  270.           no payment, either money or otherwise, for it.  Also, you must
  271.           keep all the associated files together.  The files are listed in
  272.           Appendix I.  Use PKUNZIP to unarchive.
  273.  
  274.                If you have any questions, comments or suggestions about
  275.           this program, feel free to contact me at CompuServe:
  276.  
  277.                     Lester L. Noll
  278.                     [72250,2551]
  279.  
  280.  
  281.           3  Introduction
  282.           3  Introduction
  283.  
  284.  
  285.                CrossBas will scan a Power-BASIC source file and create a
  286.           cross-reference table of variable names, labels, procedure and
  287.           function names versus the physical line numbers where those names
  288.           occur.
  289.  
  290.                To do this we must first read in all words in the file.  We
  291.           can skip text to the right of "REM" statements or "'" remark
  292.           identifiers; text to the right of "DATA" statements; text between
  293.           quote marks;  numbers;  and operators.
  294.  
  295.                After the program words are read in, we compare them with
  296.           Power-BASIC reserved words and metastatements.  We keep only
  297.           those that are not Power-BASIC words.
  298.  
  299.                Finally, we alphabetize the remaining words and print them
  300.           out, one word to a line, followed by the physical source file
  301.           line number(s) where these words are found.  The list is sorted
  302.           without regard to case.
  303.  
  304.  
  305.  
  306.           CROSSBAS.DOC                CrossBas Manual                page 2
  307.  
  308.  
  309.  
  310.                We print the list to an ASCII file and allow the user some
  311.           control over its format.  You may either print it to your printer
  312.           using the DOS PRINT or TYPE filename.ext>PRN commands or you may
  313.           use a print program such as Norton's LP.
  314.  
  315.                At the end of the file is a summary report showing
  316.           processing times, number of words processed and a few
  317.           calculations that may be helpful for customizing CrossBas to your
  318.           own programming characteristics.
  319.  
  320.  
  321.           4  Running CrossBas
  322.           4  Running CrossBas
  323.  
  324.  
  325.                Run CrossBas from the DOS command line.  There is no
  326.           interactive mode.  If you enter "CROSSBAS" with no command line
  327.           parameters, CrossBas will print a short message showing proper
  328.           syntax and the optional switches.
  329.  
  330.  
  331.           5  Command Line Options
  332.           5  Command Line Options
  333.  
  334.  
  335.                The only required command line parameter is the input file
  336.           (source file) path/name.  The output file path/name and switches
  337.           are optional.  If no output file is entered, I append ".cb" to
  338.           the input file name to create an output file name.  If a file
  339.           having the same name as output file already exists, I write over
  340.           it -- so be warned.
  341.  
  342.                Command line options can be entered in any order.  In fact,
  343.           the only rule is that the input file path/name must be entered
  344.           before the output file path/name.  You may enter switches, one
  345.           after the other, without separating spaces.  If, however, you
  346.           enter a switch before a file path/name you must leave at least
  347.           one space between the file path/name and the preceding switch.
  348.  
  349.           Syntax:
  350.  
  351.           crossbas infile[.ext][outfile][.ext][/bw][/p][/u][/s][/l:n][/w:n]
  352.  
  353.  
  354.           Switches:
  355.                /bw  Set screen colors to black and white.
  356.                /p   Paginate output file and print page headers.
  357.                /u   Print variables to output file in upper case.
  358.                /s   Print the list to the screen as well as to file.
  359.                /l:n Set the printer left margin to n columns.
  360.                /w:n Override CrossBas' word array dimension calculation.
  361.  
  362.  
  363.  
  364.           CROSSBAS.DOC                CrossBas Manual                page 3
  365.  
  366.  
  367.  
  368.           Input File                    infile                   [required]
  369.  
  370.                The input file path/name must be a valid DOS pathname.  If
  371.           no path is entered, the default path is assumed.  If the input
  372.           file path/name is not found, CrossBas prints an appropriate
  373.           message and quits.
  374.  
  375.  
  376.           Output File                   outfile                  [optional]
  377.  
  378.                The output file path/name must be formed using valid DOS
  379.           pathname and filename syntax.  If no path is entered, the default
  380.           is assumed.  If no output file path/name is entered or if the
  381.           entered output file path/name is invalid, I append ".cb" to the
  382.           input file path/name for the output file.
  383.  
  384.                I do not check if a file with the same name already exists.
  385.           If one does exist, I write over it.  If you have a main file with
  386.           the extension ".bas" and an include file with the extension
  387.           ".inc" you are responsible for providing output file names that
  388.           do not conflict with each other.  By allowing CrossBas to use its
  389.           default output file name, both cross-reference files would have
  390.           the same name, which means the second one would overwrite the
  391.           first.
  392.  
  393.  
  394.           Black & White                    /bw                   [optional]
  395.  
  396.                The black and white switch, /bw, sets the screen color to
  397.           black and white.  The default screen colors are yellow (#14)
  398.           foreground on a blue (#1) background.  The upper and lower screen
  399.           lines (lines 1 and 25) use the same colors but with foreground
  400.           and background colors reversed.  Since only colors numbered 0
  401.           through 7 are allowed for background colors, and since yellow is
  402.           14, the upper and lower screen line colors are blue foreground
  403.           and brown (#6) background (14 minus 8).
  404.  
  405.  
  406.           Paginate                       /p                      [optional]
  407.  
  408.                The paginate switch, /p, causes the output file to be
  409.           written with page breaks and page headers.  The header contains
  410.           the current system date, the page number and the source file
  411.           name.  To print a paginated file, type either "TYPE filename.ext
  412.           > PRN" or "PRINT filename.ext" from the DOS command line.  Blank
  413.           lines and form-feeds are inserted in the output file in order to
  414.           leave two blank lines at the top of the page and three blank
  415.           lines at the bottom of the page.  The header appears on line
  416.           three of each page, followed by one blank line. On line five is a
  417.           column header indicating "Variable/Label/Proc" name on the left,
  418.           and "Physical Line Number" on the right.
  419.  
  420.  
  421.  
  422.           CROSSBAS.DOC                CrossBas Manual                page 4
  423.  
  424.  
  425.  
  426.                If the paginate switch is not selected, the output file is
  427.           printed without page breaks or headers.  This method may be
  428.           preferable if you use a print formatter like Norton Utilities'
  429.           LP, which does its own page formatting.
  430.  
  431.                In either case, the summary report will be printed on the
  432.           last page without breaks.  Thus if there are not enough lines to
  433.           print the entire report on what remains of the last page, I
  434.           insert a form-feed and print it on a new page.
  435.  
  436.  
  437.           Upper-case                      /u                     [optional]
  438.  
  439.                The upper-case switch, /u, causes the variable, label,
  440.           procedure and function names to be written to the output file in
  441.           all upper-case.  If this switch is selected, two words, the same
  442.           in name but written in different case, would only appear once in
  443.           the output listing.  If this switch is not selected, for example,
  444.           "Label1:", LABEL1:" and "label1:" would all be listed separately.
  445.           If you use case to clarify your labels, such as,
  446.           "ThisIsLabelOne:", you will probably choose to not use this
  447.           switch.  Sorting is always done in upper-case order, therefore
  448.           "AAA", "aaa" and "Aaa" would be treated equally.  (Because I use
  449.           UCASE$(word$) to sort the list, the three previous examples could
  450.           appear in any order.)
  451.  
  452.  
  453.           Screen                        /s                       [optional]
  454.  
  455.                The screen switch, /s, causes the sorted list to print to
  456.           the screen at the same time it prints to the output file.  After
  457.           22 lines print to the screen, the scroll stops with a "...Press Q
  458.           to Quit screen list, any other key to continue" message.  When
  459.           you press a key the scroll continues for 22 more lines.  If you
  460.           press <Q> or <ESC> the screen list stops but output to output
  461.           file continues until the list print is completed.
  462.  
  463.           [Note:  The list prints to the output file at the same time it
  464.           prints to the screen.  Therefore, if you decide you don't want to
  465.           see anymore and press <Ctrl><Break>, you will also abort the
  466.           write to file.]
  467.  
  468.  
  469.           Left Margin                    /l:n                    [optional]
  470.  
  471.                The left margin switch and parameter, /l:n, will insert a
  472.           printer setup string at the top of the output file to set the
  473.           left margin at "n" columns.  The left margin range is 0 to 8
  474.           columns.  Since the page width is 72 columns, having a left
  475.           margin of more than 8 would push the page off the edge of an 80
  476.           column page.  If you enter a left margin greater than 8, the
  477.           value defaults to 8.
  478.  
  479.  
  480.  
  481.           CROSSBAS.DOC                CrossBas Manual                page 5
  482.  
  483.  
  484.  
  485.           [Note:  I use the Epson escape sequence, <ESC> "l" n, where n
  486.           equals the left margin column.  If you have a different printer
  487.           you must modify the code or not use this option.]
  488.  
  489.  
  490.           Word Array Dimension Override     /w:n                 [optional]
  491.  
  492.                The word dimension override switch and parameter, /w:n, will
  493.           override CrossBas' internal word dimension calculation.  You may
  494.           need to use this if the source file is less densely commented
  495.           than CrossBas expects.  Let me explain.
  496.  
  497.                CrossBas uses a string array to hold all the words read in
  498.           from the input file.  I use two default parameters to calculate
  499.           how many words to dimension the word array for.  The two
  500.           parameters are Average Word Length and Packing Factor.  The word
  501.           array will hold all of the non-comment, non-number words found in
  502.           a source file.  To calculate the word array dimension, I first
  503.           read the source file size in bytes.  Then I multiply it by the
  504.           Packing Factor.  The Packing Factor is a number, less than 1,
  505.           that represents the ratio of non-comment, non-number word bytes
  506.           versus the total bytes in the file.  Then I divide the result by
  507.           the Average Word Length.  These two parameters are read in from
  508.           the defaults file, CROSSBAS.DEF, when CrossBas first starts.
  509.  
  510.                Normally, this calculation is accurate enough.  However, if
  511.           the actual packing factor of a particular source file is
  512.           considerably greater than the default or the actual average word
  513.           length is considerably smaller than the default, you may need to
  514.           use this switch.
  515.  
  516.                To use the /w:n switch:  approximate the number of words,
  517.           both Power-BASIC reserved words and non-reserved words: labels,
  518.           procedure names, function names, variable names, in the source
  519.           file.  Do not include comment words, data words or numbers in the
  520.           total.  This number will become the 'n' parameter of the word
  521.           array dimension switch.
  522.  
  523.  
  524.           6  Changing Defaults File
  525.           6  Changing Defaults File
  526.  
  527.  
  528.                You can change the defaults file with any ASCII editor.
  529.           When you run CrossBas the first time it will create CROSSBAS.DEF.
  530.           The next time it runs it will look for that file in the default
  531.           directory.  If it finds it, CrossBas will read in two parameters:
  532.           Average Word Length, and Packing Factor.
  533.  
  534.                These two parameters are both in the first line of the
  535.           defaults file, separated by a comma.  The rest of the defaults
  536.           file contains a few lines of text explaining the default
  537.           parameters.  You may do anything you like to this file except
  538.           modify the format of the first line.  Change the values, if you
  539.           like but be sure the first number, the Average Word Length, is a
  540.  
  541.  
  542.  
  543.           CROSSBAS.DOC                CrossBas Manual                page 6
  544.  
  545.  
  546.  
  547.           number greater than one.  Likewise, the second number, the
  548.           Packing Factor, must be a decimal number less than one.  The two
  549.           numbers must be separated by a comma.
  550.  
  551.                To determine the best default parameters, check the summary
  552.           report, at the end of your CrossBas listings.  It shows the
  553.           default values used by CrossBas.  It also shows the actual
  554.           parameters that CrossBas found after reading in the words from
  555.           the source file.  After CrossBas-ing a few of your source files,
  556.           you can get an idea of the Average Word Lengths and Packing
  557.           Factors you use in your files.
  558.  
  559.  
  560.           7  The Summary Report
  561.           7  The Summary Report
  562.  
  563.  
  564.                A summary report appears at the end of the CrossBas cross-
  565.           reference file listing.
  566.  
  567.                The top two-thirds of the report is the same as what
  568.           CrossBas prints to the screen as it processes the source file.
  569.  
  570.                Your command line options are listed on the top two rows.
  571.  
  572.                The next three lines show the read and parse procedure
  573.           statistics.  This is where CrossBas reads in source file text
  574.           lines, parses them into words and saves all the words that are
  575.           not comments (REM or '), data words (DATA), operators (*, AND, =,
  576.           etc.), or numbers.  The remaining words get stored in a word
  577.           array.  Line number references for each of the saved words are
  578.           stored in a line number array.  These three lines show the number
  579.           of lines in the source file, the number of words saved to the
  580.           word array and the start, end and elapsed processing times.
  581.  
  582.                The next three lines show the compare procedure statistics.
  583.           Up to this point, the word array contains Power-BASIC reserved
  584.           words, label names, variable names, subprogram (SUB) names and
  585.           function (FN) names.  Now CrossBas compares each word in the word
  586.           array with Power-BASIC reserved words.  If the words compare we
  587.           do not save them.  These three report lines show the number of
  588.           words compared, the number of non-Power-BASIC words in the source
  589.           file (if the same word appears 5 times then it is counted as 5
  590.           words at this point) and the start, end and elapsed processing
  591.           times.
  592.  
  593.                The next two lines show the sort procedure statistics.
  594.           CrossBas sorts the remaining words in alphabetical order, without
  595.           regard for case.  These two report lines show the number of words
  596.           sorted and the start, end and elapsed processing times.
  597.  
  598.                The next two lines show the printing to file statistics.
  599.           CrossBas prints the sorted words to the output file in the manner
  600.           specified by the command line options.  These two lines show the
  601.           number of unique words (if the same word appears 5 times it is
  602.  
  603.  
  604.  
  605.           CROSSBAS.DOC                CrossBas Manual                page 7
  606.  
  607.  
  608.  
  609.           counted as only one unique word) printed to the output file and
  610.           the start, end and elapsed processing times.
  611.  
  612.                The next line shows the total CrossBas processing times:
  613.           start, end and elapsed, from the start of the read and parse
  614.           procedure to the end of the print to file procedure.
  615.  
  616.                Next we have an analysis of the source file.  Use this to
  617.           help you customize your CROSSBAS.DEF file.
  618.  
  619.                The total number of bytes used by the word array is taken at
  620.           the time when it contained both non-reserved words (labels,
  621.           procedures, functions, variables) and Power-BASIC reserved words.
  622.           I use this figure (actually a projection of this figure using the
  623.           input file length and the default Packing Factor) to determine if
  624.           there will be enough string space to process the source file.
  625.  
  626.                The default word array dimension is the number used to
  627.           dimension the word array.  This is a calculated value unless you
  628.           included a command line override (/w:n).  The command line
  629.           override is shown at the top of the report.  If no override
  630.           option was included, the screen report will show "No o/r."
  631.  
  632.                The actual word array dimension is the actual number of
  633.           words found in the source file.
  634.  
  635.                The default Average Word Length is the number read in from
  636.           the CROSSBAS.DEF file.  I use this, along with the default
  637.           Packing Factor, to calculate the default word array dimension.
  638.  
  639.                The actual average word length is the actual average word
  640.           length of the non-reserved words in the source file.  I guess
  641.           that explains itself.
  642.  
  643.                The default Packing Factor is the number read in from the
  644.           CROSSBAS.DEF file (a number less than one).  I use this, along
  645.           with the Average Word Length, to calculate the word array
  646.           dimension.  I use this also to determine if there is enough
  647.           string space to process the source file.
  648.  
  649.                Finally, we list the source and output file names and sizes.
  650.  
  651.  
  652.  
  653.           CROSSBAS.DOC                CrossBas Manual                page 8
  654.  
  655.  
  656.  
  657.                                -+-+-+- Summary Report -+-+-+-
  658.  
  659.           Options: Upper-case:  No     Screen:   No       Paginate:  Yes
  660.                    Left Margin: 6      ArrayDim: No o/r
  661.  
  662.           Read:      448 lines from source file CROSSBAS.INC
  663.           Found:     919 non-comment words.
  664.           Times:     Start: 15:06:59  End: 15:07:16  Elapsed: 00:00:17
  665.  
  666.           Compared:  919 non-comment words from source file CROSSBAS.INC
  667.           Found:     432 non-reserved words (variables, labels, procedures)
  668.           Times:     Start: 15:07:17  End: 15:07:27  Elapsed: 00:00:10
  669.  
  670.           Sorted:    432 non-reserved words (variables, labels, procedures)
  671.           Times:     Start: 15:07:28  End: 15:08:01  Elapsed: 00:00:33
  672.  
  673.           Printed:   93 unique, non-reserved words to CROSSBAS.CBI
  674.           Times:     Start: 15:08:02  End: 15:08:04  Elapsed: 00:00:02
  675.  
  676.           Totals:    Start: 15:06:59  End: 15:08:04  Elapsed: 00:01:05
  677.  
  678.           Word Array Size:   4,852 bytes
  679.           Default Word Array Dim.:  1,124 wds  Actual Word Array Dim.:    919 wds
  680.           Default Avg.Word Length:      6 byt  Actual Avg.Word Length:      5 byt
  681.           Default Packing Factor:   45.00 %    Actual Packing Factor:   32.35 %
  682.  
  683.           Source,    CROSSBAS.INC, File size:  14,998 bytes
  684.           Cross-Ref, CROSSBAS.CBI, File size:   6,984 bytes
  685.  
  686.  
  687.                               Figure 1: Summary Report Example
  688.                               Figure 1
  689.  
  690.  
  691.  
  692.           8  What CrossBas Does
  693.           8  What CrossBas Does
  694.  
  695.  
  696.                CrossBas' main program flow consists of a series of GOSUB-
  697.           type subroutines.  The following is a description of each one in
  698.           the order in which they occur.
  699.  
  700.           8.1  Initialize
  701.           8.1  Initialize
  702.  
  703.                Initialize the screen type and color variables.  Most of my
  704.           numbers will be integers so I define all number variables as
  705.           integers.  Set up an error trap.
  706.  
  707.           8.2  InitScreen
  708.           8.2  InitScreen
  709.  
  710.                Print initializing message to the screen.
  711.  
  712.  
  713.  
  714.           CROSSBAS.DOC                CrossBas Manual                page 9
  715.  
  716.  
  717.  
  718.           8.3  ReadCmdLine
  719.           8.3  ReadCmdLine
  720.  
  721.                Read in the DOS command line parameters.  Set up the
  722.           paginate, screen print and upper-case flags, and the left margin
  723.           and word array dimension variables.  Get input file path/name.
  724.           The second parameter that is not a valid switch is assumed to be
  725.           the output file path/name.  If no input file path/name is found
  726.           then print the appropriate message to the screen and die.
  727.  
  728.           8.4  OpenFiles
  729.           8.4  OpenFiles
  730.  
  731.                Attempt to open the input and output files.  If I fail while
  732.           opening the input file, I check to see if it has an extension.
  733.           If it doesn't, I append ".bas" and try again.  If I fail again, I
  734.           print the appropriate message to the screen and die.
  735.  
  736.                If the input I open the input file ok, I next attempt to
  737.           open the output file.  If no file path/name is given I append
  738.           ".cb" to the end of the input file (after stripping the
  739.           extension, if one exists).  If I fail, I somewhere along the way,
  740.           I print the appropriate message to the screen and die.  If I am
  741.           successful I close the output file until I'm ready to write to
  742.           it.
  743.  
  744.           [Note:  A previously existing file with the same name as the
  745.           output file is, at this point, replaced by a file of 0 bytes.]
  746.  
  747.           8.5  CalcFileNames
  748.           8.5  CalcFileNames
  749.  
  750.                Strip off the drive and directory specs from the input and
  751.           output file path/names.  I use these stripped names for output
  752.           file page headers and screen and file report headers.
  753.  
  754.           8.6  ReadDefaults
  755.           8.6  ReadDefaults
  756.  
  757.                Read in the default values for Average Word Length and
  758.           Packing Factor from the defaults file, CROSSBAS.DEF.  If this
  759.           file does not exist, I make one.
  760.  
  761.                If you run CrossBas from other than its home directory, it
  762.           will not find its defaults file and will create a new one in the
  763.           default directory.  This won't bother CrossBas but if you have
  764.           modified the CROSSBAS.DEF and are assuming your modified default
  765.           parameters will be used, you may be surprised.  In that case, you
  766.           had better change directory to the CrossBas directory and run the
  767.           program from there.  See the default section for more on
  768.           modifying the defaults file.
  769.  
  770.  
  771.  
  772.           CROSSBAS.DOC                CrossBas Manual               page 10
  773.  
  774.  
  775.  
  776.           8.7  CheckStringSpace
  777.           8.7  CheckStringSpace
  778.  
  779.           [Note:  I removed this subroutine from the Power-BASIC version of
  780.           CrossBas because of PB's increased string space capacity.  To use
  781.           it with Turbo-BASIC, reinstall.]
  782.  
  783.                Check to see that there is enough free string space for
  784.           storing the anticipated input file words.  I read the input file
  785.           size and multiply it by the packing factor.  This should give me
  786.           the approximate number of bytes of non-comment, non-number words
  787.           in the input file.  Then I compare this "effective file size"
  788.           with the free string space.  If not enough string space, I print
  789.           the appropriate message to the screen and die.
  790.  
  791.           8.8  CalcWordArraySize
  792.           8.8  CalcWordArraySize
  793.  
  794.                First check to see if there is a command line Word Array
  795.           Dimension override (/w:n).  If so, use this value to dimension
  796.           the word array.
  797.  
  798.                If not calculate the approximate number of words in the
  799.           input file.  Find the effective input file size by multiplying
  800.           the input file size by the Packing Factor.  Then divide the
  801.           effective file size by the Average Word Length.  Packing Factor
  802.           and Average Word Length are values read in from the defaults file
  803.           in the ReadDefaults section.
  804.  
  805.           8.9  PrintScreenTop
  806.           8.9  PrintScreenTop
  807.  
  808.                Print the first few lines of the screen report.  These show
  809.           the input file name, less any drive or directory specifications;
  810.           the condition of the three command line switch flags; and the
  811.           option values for left margin and word array dimension override.
  812.  
  813.           8.10  ReadAndParseData
  814.           8.10  ReadAndParseData
  815.  
  816.                Read in the input file line by line, and parse out the non-
  817.           comment, non-number words.  Save these words, along with their
  818.           physical line numbers in separate arrays.  Keep a running total
  819.           of the bytes in the word array.  Print the current input file
  820.           line number and word to the status bar at the bottom of the
  821.           screen after every input file line.
  822.  
  823.                Also, check the free string space after each line and, if it
  824.           gets below 300 bytes (249 column limit per line, plus a few extra
  825.           for good measure) then abort and print the appropriate message to
  826.           the screen and die.
  827.  
  828.           8.11  PrintScreen1
  829.           8.11  PrintScreen1
  830.  
  831.                Print the number of lines read from the input file, the
  832.           number of non-comment, non-number words read and saved in the
  833.           word array, and the start and end times for the operation to the
  834.           screen.
  835.  
  836.  
  837.  
  838.           CROSSBAS.DOC                CrossBas Manual               page 11
  839.  
  840.  
  841.  
  842.           8.12  Compare
  843.           8.12  Compare
  844.  
  845.                Compare the word array words with Power-BASIC reserved
  846.           words.  If the words are not Power-BASIC words, then save them
  847.           and their associated line-number array elements.  Print the
  848.           current word number to the status bar at the bottom of the screen
  849.           after every non-Power-BASIC word is saved.
  850.  
  851.                By checking the first letter of the word array word, I only
  852.           need to compare the word array word with Power-BASIC words
  853.           beginning with the same letter.  Save the non-Power-BASIC words
  854.           back into the same array but at a lower location.
  855.  
  856.                Lets say words 1,2 and 3 were Power-BASIC words.  Word 4 is
  857.           a label.  Therefore I save word array element number 4 back to
  858.           the same array but as element 1.  I also save the associated
  859.           line-number array element, in this case, 4 to 1.
  860.  
  861.                When I have compared all the words in the array, I blank out
  862.           the remaining, non-used elements in the word array to free up
  863.           string space.
  864.  
  865.           8.13  PrintScreen2
  866.           8.13  PrintScreen2
  867.  
  868.                Print the number of non-reserved words saved back to the
  869.           word array and the start and end times for the operation to the
  870.           screen.
  871.  
  872.           8.14  Sort
  873.           8.14  Sort
  874.  
  875.                Sort the remaining non-Power-BASIC words into alphabetical
  876.           order.  I use a modified bubble sort and compare upper-case
  877.           values of the words.  Print the current pass to the status bar at
  878.           the bottom of the screen.
  879.  
  880.                If there are J words in the word array then I make J-1
  881.           passes through the array, comparing a word with the word after
  882.           it.  If the words are in order, I check the next two words.  If
  883.           the words are out of order I swap them and their associated
  884.           line-number array elements.  If I make an entire pass without
  885.           making any swaps, then the sorting is complete.
  886.  
  887.           8.15  PrintScreen3
  888.           8.15  PrintScreen3
  889.  
  890.                Print the number of non-reserved words sorted and the start
  891.           and end times for the operation to the screen.
  892.  
  893.           8.16  PrintList
  894.           8.16  PrintList
  895.  
  896.                Print the word list to the output file.  The words are
  897.           listed in the left column.  The associated line numbers are
  898.           listed in the right eight columns.  Print the current page and
  899.           word number to the status bar at the bottom of the screen.
  900.  
  901.  
  902.  
  903.           CROSSBAS.DOC                CrossBas Manual               page 12
  904.  
  905.  
  906.  
  907.             o  If a left margin (/l:n) is selected, print the printer setup
  908.                string at the top of the file.
  909.             o  If the upper-case switch (/u) is selected, convert the words
  910.                at print time.
  911.             o  If the screen print switch (/s) is selected, print the words
  912.                and line-numbers to the screen as they print to file.
  913.             o  If the paginate switch (/p) is selected, print a page header
  914.                at the top of each page and a form-feed at the bottom of
  915.                each page.
  916.  
  917.           8.17  PrintReportBtm
  918.           8.17  PrintReportBtm
  919.  
  920.                Print the summary report on the last page of the report.  If
  921.           the paginate switch (/s) is selected then if there is not enough
  922.           room on the last page for the entire report, send out a form-feed
  923.           and put it on a new page.  If the paginate switch is not selected
  924.           then send out a form-feed to start a new page.
  925.  
  926.                The report contains read, compare, sort and print
  927.           information, similar to that displayed on the screen.
  928.           Additionally I print total procedure times; source and output
  929.           file sizes; word array words and bytes, both default and actual;
  930.           and Packing Factors and Average Word Lengths, default and actual.
  931.  
  932.           8.18  PrintScreen4
  933.           8.18  PrintScreen4
  934.  
  935.                Print the number of unique words printed to the output file
  936.           and the start and end times for the operation to the screen.
  937.           Erase the status bar and print a "CrossBas finished" message.
  938.  
  939.           8.19  End Routines
  940.           8.19  End Routines
  941.  
  942.                Finally, I close all open files, flush the keyboard buffer
  943.           and wait for the user to acknowledge he has read the report
  944.           screen by pressing a key.  I included this step because some
  945.           versions of DOS erase the screen when they reload COMMAND.COM.
  946.  
  947.  
  948.  
  949.           CROSSBAS.DOC                CrossBas Manual               page 13
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.                                      Appendix AAppendix A
  960.  
  961.                                    CrossBas FilesCrossBas Files
  962.  
  963.  
  964.                CrossBas uses the following files:
  965.  
  966.           CRSBAS.ZIP          CrossBas archive file that contains the
  967.                               CrossBas files.
  968.           CROSSBAS.EXE        CrossBas executable file.
  969.           CROSSBAS.DEF        CrossBas defaults file.  (CrossBas creates
  970.                               this file the first time it runs.)
  971.           CROSSBAS.BAS        CrossBas main source file.
  972.           CROSSBAS.INC        CrossBas subprograms file.
  973.           CROSSBAS.DOC        CrossBas document file (this file).
  974.  
  975.  
  976.  
  977.           CROSSBAS.DOC                CrossBas Manual               page 14
  978.  
  979.  
  980.  
  981.           CROSSBAS.DOC                CrossBas Manual               page 15
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.                                      Appendix BAppendix B
  992.  
  993.                                 Modification HistoryModification History
  994.  
  995.  
  996.           version 1.00P     12/ 1/90
  997.  
  998.           Uploaded CrossBas version 1.00P to CompuServe PCVENB, Spectra
  999.           forum.
  1000.  
  1001.           version 1.000     11/13/89
  1002.  
  1003.           Uploaded CrossBas version. 1.00 to CompuServe BPROGA forum,
  1004.           LIB 9.
  1005.  
  1006.           KEYWORDS:  CROSS-REFERENCE, TABLE, LIST, NON-RESERVED WORDS,
  1007.                      BASIC, CREF, XREF
  1008.  
  1009.           Description:   CrossBas will read in a Power-BASIC source file
  1010.                          and create an alphabetized cross-reference listing
  1011.                          of non-reserved words, i.e., variable, subprogram,
  1012.                          function and label names, along with the physical
  1013.                          line number(s) where they appear.  The list is
  1014.                          printed to file.  Handy for cleaning up unused
  1015.                          variable names, labels, etc.
  1016.  
  1017.  
  1018.  
  1019.           CROSSBAS.DOC                CrossBas Manual               page 16
  1020.  
  1021.  
  1022.  
  1023.           CROSSBAS.DOC                CrossBas Manual               page 17
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.                                      Appendix CAppendix C
  1034.  
  1035.                              Power-BASIC Reserved WordsPower-BASIC Reserved Words
  1036.  
  1037.  
  1038.           $COM             BLOAD            DEF              FILEATTR()
  1039.           $COM1            BSAVE            DEFBCD           FILES
  1040.           $COM2                             DEFDBL           FIX()
  1041.           $COMPILE         CALL             DEFEXT           FIXDIGITS
  1042.           $CPU             CASE             DEFFIX           FLEXCHR$
  1043.           $DEBUG           CBCD()           DEFFLX           FN
  1044.           $DYNAMIC         CDBL()           DEFINT           FOR
  1045.           $ELSE            CEIL()           DEFLNG           FRE()
  1046.           $ENDIF           CTEXT()          DEFQUD           FREEFILE
  1047.           $ERROR           CFIX()           DEFSNG           FROM
  1048.           $EVENT           CHAIN            DEFSTR           FUNCTION
  1049.           $FLOAT           CHDIR            DELAY
  1050.           $IF              CHR$()           DELETE           GET
  1051.           $INCLUDE         CINT()           DESCEND          GET()
  1052.           $INLINE          CIRCLE()         DIM              GET$
  1053.           $LIB             CLEAR            DO               GOSUB
  1054.           $LINK            CLNG()           DRAW             GOTO
  1055.           $LIST            CLOSE            DYNAMIC
  1056.           $OPTION          CLS                               HEX$()
  1057.           $SEGMENT         COLLATE          ELSE
  1058.           $SOUND           COLOR            ELSEIF           IF
  1059.           $STACK           COM()            END              IMP
  1060.           $STATIC          COMMAND$         ENDMEM           IN
  1061.           $STRING          COMMON           ENVIRON          INCR
  1062.                            COS()            ENVIRON$()       INKEY$
  1063.           ABS()            CQUD()           EOF()            INP()
  1064.           ABSOLUTE         CSNG()           EQV              INPUT
  1065.           AND              CSRLIN           ERADR            INPUT #
  1066.           ANY              CVB()            ERASE            INPUT$()
  1067.           APPEND           CVD()            ERDEV            INSERT
  1068.           ARRAY            CVE()            ERDEV$           INSTAT
  1069.           AS               CVF()            ERL              INSTR()
  1070.           ASC()            CVI()            ERR              INT()
  1071.           ASCEND           CVL()            ERROR            INTERRUPT
  1072.           ASCII()          CVMD()           EXECUTE          IOCTL
  1073.           DATA             CVMS()           EXIT             IOCTL$
  1074.           AT               CVQ()            EXP()
  1075.           ATN()            CVS()            EXP10()          KEY
  1076.                                             EXP2()           KEY()
  1077.           BASE             DATA             EXTERNAL         KILL
  1078.           BEEP             DATE$            EXTRACT$()
  1079.           BIN$()           DECLARE                           LBOUND()
  1080.           BINARY           DECR             FIELD            LCASE$()
  1081.  
  1082.  
  1083.  
  1084.           CROSSBAS.DOC                CrossBas Manual               page 18
  1085.  
  1086.  
  1087.  
  1088.           LEFT$()          OCT$()           RESET            TALLY()
  1089.           LEN()            OFF              RESTORE          TAN()
  1090.           LET              ON               RESUME           THEN
  1091.           LINE             OPEN             RETURN           TIME$
  1092.           LINE()           OPTION           RIGHT$()         TIMER
  1093.           LIST             OR               RMDIR            TIMER()
  1094.           LOC()            OUT              RND              TO
  1095.           LOCAL            OUTPUT           RND()            TROFF
  1096.           LOCATE                            ROUND()          TRON
  1097.           LOF()            PAINT()          RSET
  1098.           LOG()            PALETTE          RTRIM$()         UBOUND()
  1099.           LOG10()          PEEK()           RUN              UCASE
  1100.           LOG2()           PEEK$()                           UCASE$()
  1101.           LOOP             PEEKI()          SAVE             UNTIL
  1102.           LPOS()           PEEKL()          SCAN             USING
  1103.           LPRINT           PEN              SCREEN           USING$()
  1104.           LPRINT #         PEN()            SCREEN()         USR
  1105.           LSET             PLAY             SEEK             USR0
  1106.           LTRIM$()         PLAY()           SEG              USR1
  1107.                            PMAP()           SELECT           USR2
  1108.           MAP              POINT()          SERVICE          USR3
  1109.           MAX()            POKE             SGN()            USR4
  1110.           MAX$()           POKE$            SHARED           USR5
  1111.           MAX%()           POKEI            SHELL            USR6
  1112.           MEMSET           POKEL            SIN()            USR7
  1113.           MID$()           POS              SORT             USR8
  1114.           MIN()            POS()            SOUND            USR9
  1115.           MIN$()           PRESET           SPACE$()
  1116.           MIN%()           PRINT            SPC()            VAL()
  1117.           MKDIR            PRINT #          SQR()            VARPTR()
  1118.           MKB$()           PSET()           STATIC           VARPTR$()
  1119.           MKD$()           PUBLIC           STEP             VARSEG()
  1120.           MKE$()           PUT              STICK()          VERIFY()
  1121.           MKF$()           PUT()            STOP             VIEW
  1122.           MKI$()           PUT$             STR$()           VIEW()
  1123.           MKL$()                            STRIG
  1124.           MKMD$()          RANDOM           STRIG()          WAIT
  1125.           MKMS$()          RANDOMIZE        STRING$()        WEND
  1126.           MKQ$()           READ             STRPTR()         WHILE
  1127.           MKS$()           REDIM            STRSEG()         WIDTH
  1128.           MOD              REG              SUB              WINDOW
  1129.           MTIMER           REG()            SWAP             WINDOW()
  1130.                            REM              SYSTEM           WITH
  1131.           NAME             REMOVE$()                         WRITE
  1132.           NEXT             REPEAT$()        TAB()            WRITE #
  1133.           NOT              REPLACE          TAGARRAY
  1134.                                                              XOR
  1135.